/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Admin.java
 *
 * Created on Aug 28, 2010, 11:26:41 AM
 */

package GUI;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import BusinessLogic.*;
import java.util.Vector;
import javax.swing.table.TableModel;
/**
 *
 * @author thangvv0907i
 */
public class Admin extends javax.swing.JPanel {

    /** Creates new form Admin */
    private User user;
    public Admin(User userObj) {
        user = userObj;
        initComponents();
        function=new AdminFunction();
        getValuesForUserTable();
        CategoryList();
        ItemList();
        GenerateCateID();
        CateList();        
        txtName.setText(user.getName());
        txtPhone.setText(user.getPhone());
        txtEmail.setText(user.getEmail());
        txtAddress.setText(user.getAddress());
        txtUserName.setText(user.getUserName());
        txtRoles.setText(user.getRole());
        txtPer.setText(Integer.toString(user.getPermiss()));
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        tp_Admin = new javax.swing.JTabbedPane();
        pn_info = new javax.swing.JPanel();
        pn_PersonInfo = new javax.swing.JPanel();
        lb_Address = new javax.swing.JLabel();
        lb_phone = new javax.swing.JLabel();
        lb_Email = new javax.swing.JLabel();
        txtPhone = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtAddress = new javax.swing.JTextArea();
        bnt_Change = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        pn_MangerInfo = new javax.swing.JPanel();
        lb_username = new javax.swing.JLabel();
        lb_Roles = new javax.swing.JLabel();
        lb_permis = new javax.swing.JLabel();
        txtUserName = new javax.swing.JTextField();
        txtRoles = new javax.swing.JTextField();
        txtPer = new javax.swing.JTextField();
        bntChangePass = new javax.swing.JButton();
        pn_user = new javax.swing.JPanel();
        pn_PersonInfo1 = new javax.swing.JPanel();
        lb_Address1 = new javax.swing.JLabel();
        lb_phone1 = new javax.swing.JLabel();
        lb_Email1 = new javax.swing.JLabel();
        txtEmail1 = new javax.swing.JTextField();
        txtPhone1 = new javax.swing.JTextField();
        lb_Name = new javax.swing.JLabel();
        txtName1 = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtAddress1 = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        txtUID = new javax.swing.JTextField();
        pn_MangerInfo1 = new javax.swing.JPanel();
        lb_username1 = new javax.swing.JLabel();
        lb_Roles1 = new javax.swing.JLabel();
        txtUserName1 = new javax.swing.JTextField();
        cbRoles = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        txtPass1 = new javax.swing.JPasswordField();
        jLabel5 = new javax.swing.JLabel();
        rbEnable = new javax.swing.JRadioButton();
        rbDisable = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tbUser = new javax.swing.JTable();
        bntAddUser = new javax.swing.JButton();
        bntResetUser = new javax.swing.JButton();
        bntUpdateUser = new javax.swing.JButton();
        pn_Item = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tbItem = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        lb_IID = new javax.swing.JLabel();
        lb_IName = new javax.swing.JLabel();
        lb_Cate = new javax.swing.JLabel();
        lb_Unit = new javax.swing.JLabel();
        lb_Quantity = new javax.swing.JLabel();
        lb_Price = new javax.swing.JLabel();
        txtIID = new javax.swing.JTextField();
        txtIName = new javax.swing.JTextField();
        cbCate = new javax.swing.JComboBox();
        txtUnit = new javax.swing.JTextField();
        txtQuantity = new javax.swing.JTextField();
        txtPrice = new javax.swing.JTextField();
        bntAddItem = new javax.swing.JButton();
        bntUpdateItem = new javax.swing.JButton();
        bntDeleteItem = new javax.swing.JButton();
        bntResetItem = new javax.swing.JButton();
        pn_Cate = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        lb_CateID = new javax.swing.JLabel();
        lb_CateName = new javax.swing.JLabel();
        txtCateID = new javax.swing.JTextField();
        txtCateName = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tbCategory = new javax.swing.JTable();
        bntAddCate = new javax.swing.JButton();
        bntReset = new javax.swing.JButton();
        bntUpdate = new javax.swing.JButton();
        bntDelete = new javax.swing.JButton();

        tp_Admin.setBackground(new java.awt.Color(204, 255, 255));

        pn_info.setLayout(null);

        pn_PersonInfo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Personal Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_Address.setText("Address :");

        lb_phone.setText("Phone :");

        lb_Email.setText("Email :");

        txtAddress.setColumns(20);
        txtAddress.setRows(5);
        jScrollPane1.setViewportView(txtAddress);

        bnt_Change.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bnt_Change.setText("Update");
        bnt_Change.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bnt_ChangeActionPerformed(evt);
            }
        });

        jLabel1.setText("Name :");

        javax.swing.GroupLayout pn_PersonInfoLayout = new javax.swing.GroupLayout(pn_PersonInfo);
        pn_PersonInfo.setLayout(pn_PersonInfoLayout);
        pn_PersonInfoLayout.setHorizontalGroup(
            pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_PersonInfoLayout.createSequentialGroup()
                .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pn_PersonInfoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lb_Address)
                            .addComponent(lb_phone))
                        .addGap(18, 18, 18)
                        .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                            .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                            .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pn_PersonInfoLayout.createSequentialGroup()
                        .addGap(106, 106, 106)
                        .addComponent(bnt_Change)))
                .addGap(33, 33, 33))
            .addGroup(pn_PersonInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lb_Email)
                .addContainerGap(247, Short.MAX_VALUE))
            .addGroup(pn_PersonInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(244, Short.MAX_VALUE))
        );
        pn_PersonInfoLayout.setVerticalGroup(
            pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_PersonInfoLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(39, 39, 39)
                .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_phone)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(45, 45, 45)
                .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Email, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(39, 39, 39)
                .addGroup(pn_PersonInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_PersonInfoLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(46, 46, 46)
                        .addComponent(bnt_Change))
                    .addComponent(lb_Address))
                .addGap(7, 7, 7))
        );

        pn_info.add(pn_PersonInfo);
        pn_PersonInfo.setBounds(50, 30, 300, 420);

        pn_MangerInfo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Management Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_username.setText("UserName :");

        lb_Roles.setText("Roles :");

        lb_permis.setText("Permisson :");

        txtUserName.setEnabled(false);

        txtRoles.setEnabled(false);

        txtPer.setEnabled(false);

        bntChangePass.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bntChangePass.setText("Change Password");
        bntChangePass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntChangePassActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pn_MangerInfoLayout = new javax.swing.GroupLayout(pn_MangerInfo);
        pn_MangerInfo.setLayout(pn_MangerInfoLayout);
        pn_MangerInfoLayout.setHorizontalGroup(
            pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_MangerInfoLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lb_username)
                    .addComponent(lb_Roles)
                    .addComponent(lb_permis))
                .addGap(49, 49, 49)
                .addGroup(pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(txtRoles)
                    .addComponent(txtPer))
                .addContainerGap(14, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pn_MangerInfoLayout.createSequentialGroup()
                .addContainerGap(82, Short.MAX_VALUE)
                .addComponent(bntChangePass, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(48, 48, 48))
        );
        pn_MangerInfoLayout.setVerticalGroup(
            pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_MangerInfoLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_username)
                    .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37)
                .addGroup(pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_Roles)
                    .addComponent(txtRoles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(pn_MangerInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_permis)
                    .addComponent(txtPer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 174, Short.MAX_VALUE)
                .addComponent(bntChangePass)
                .addContainerGap())
        );

        pn_info.add(pn_MangerInfo);
        pn_MangerInfo.setBounds(410, 30, 316, 420);

        tp_Admin.addTab("Information", new javax.swing.ImageIcon(getClass().getResource("/Images/Information-icon.png")), pn_info); // NOI18N

        pn_PersonInfo1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Personal Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_Address1.setText("Address :");

        lb_phone1.setText("Phone :");

        lb_Email1.setText("Email :");

        lb_Name.setText("Name :");

        txtAddress1.setColumns(20);
        txtAddress1.setRows(5);
        jScrollPane2.setViewportView(txtAddress1);

        jLabel3.setText("User ID :");

        javax.swing.GroupLayout pn_PersonInfo1Layout = new javax.swing.GroupLayout(pn_PersonInfo1);
        pn_PersonInfo1.setLayout(pn_PersonInfo1Layout);
        pn_PersonInfo1Layout.setHorizontalGroup(
            pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_PersonInfo1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lb_phone1)
                    .addComponent(jLabel3)
                    .addComponent(lb_Name)
                    .addComponent(lb_Email1)
                    .addComponent(lb_Address1))
                .addGap(18, 18, 18)
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                    .addComponent(txtName1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                    .addComponent(txtUID, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                    .addComponent(txtEmail1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                    .addComponent(txtPhone1, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
                .addGap(64, 64, 64))
        );
        pn_PersonInfo1Layout.setVerticalGroup(
            pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_PersonInfo1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtUID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_Name)
                    .addComponent(txtName1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Email1))
                .addGap(18, 18, 18)
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPhone1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_phone1))
                .addGap(18, 18, 18)
                .addGroup(pn_PersonInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lb_Address1)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pn_MangerInfo1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Management Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_username1.setText("UserName :");

        lb_Roles1.setText("Roles :");

        cbRoles.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "----Choose Roles For User----", "Inventory Manager", "Sales Manager", "Sales Men" }));

        jLabel4.setText("PassWord :");

        jLabel5.setText("Status :");

        buttonGroup2.add(rbEnable);
        rbEnable.setText("Enable");

        buttonGroup2.add(rbDisable);
        rbDisable.setText("Disable");

        javax.swing.GroupLayout pn_MangerInfo1Layout = new javax.swing.GroupLayout(pn_MangerInfo1);
        pn_MangerInfo1.setLayout(pn_MangerInfo1Layout);
        pn_MangerInfo1Layout.setHorizontalGroup(
            pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                        .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lb_username1)
                            .addComponent(lb_Roles1)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbRoles, 0, 212, Short.MAX_VALUE)
                            .addComponent(txtUserName1, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtPass1, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE))
                        .addContainerGap(98, Short.MAX_VALUE))
                    .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(rbEnable)
                        .addGap(18, 18, 18)
                        .addComponent(rbDisable)
                        .addContainerGap(180, Short.MAX_VALUE))))
        );
        pn_MangerInfo1Layout.setVerticalGroup(
            pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_username1)
                    .addComponent(txtUserName1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34)
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtPass1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_Roles1)
                    .addComponent(cbRoles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(rbEnable)
                        .addComponent(rbDisable))
                    .addComponent(jLabel5))
                .addContainerGap(44, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Users List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        tbUser.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbUserMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(tbUser);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 758, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
        );

        bntAddUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Add-icon.png"))); // NOI18N
        bntAddUser.setText("Add New");
        bntAddUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntAddUserActionPerformed(evt);
            }
        });

        bntResetUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Undo-icon.png"))); // NOI18N
        bntResetUser.setText("Reset");
        bntResetUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntResetUserActionPerformed(evt);
            }
        });

        bntUpdateUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bntUpdateUser.setText("Update");
        bntUpdateUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntUpdateUserActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pn_userLayout = new javax.swing.GroupLayout(pn_user);
        pn_user.setLayout(pn_userLayout);
        pn_userLayout.setHorizontalGroup(
            pn_userLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_userLayout.createSequentialGroup()
                .addGroup(pn_userLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_userLayout.createSequentialGroup()
                        .addGap(79, 79, 79)
                        .addComponent(bntAddUser)
                        .addGap(130, 130, 130)
                        .addComponent(bntUpdateUser)
                        .addGap(145, 145, 145)
                        .addComponent(bntResetUser))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pn_userLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(pn_PersonInfo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(pn_MangerInfo1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pn_userLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        pn_userLayout.setVerticalGroup(
            pn_userLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_userLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(pn_userLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pn_MangerInfo1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pn_PersonInfo1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pn_userLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bntAddUser)
                    .addComponent(bntUpdateUser)
                    .addComponent(bntResetUser))
                .addGap(34, 34, 34))
        );

        tp_Admin.addTab("User Manager", new javax.swing.ImageIcon(getClass().getResource("/Images/User-icon.png")), pn_user); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Items List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        tbItem.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbItemMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tbItem);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 758, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Items Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_IID.setText("Item's ID :");

        lb_IName.setText("Item's Name :");

        lb_Cate.setText("Category :");

        lb_Unit.setText("Unit :");

        lb_Quantity.setText("Quantity :");

        lb_Price.setText("Price :");

        cbCate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "------  Choice Category  ------" }));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lb_IName)
                    .addComponent(lb_IID)
                    .addComponent(lb_Unit)
                    .addComponent(lb_Cate))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtUnit, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addComponent(txtIName, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addComponent(txtIID, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addComponent(cbCate, 0, 169, Short.MAX_VALUE))
                .addGap(29, 29, 29)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lb_Quantity)
                    .addComponent(lb_Price))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(txtPrice, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtQuantity, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                .addContainerGap(208, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtIID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Quantity)
                    .addComponent(lb_IID))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Price)
                    .addComponent(lb_IName))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbCate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Cate))
                .addGap(6, 6, 6)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtUnit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Unit))
                .addContainerGap())
        );

        bntAddItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Add-icon.png"))); // NOI18N
        bntAddItem.setText("Add New");
        bntAddItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntAddItemActionPerformed(evt);
            }
        });

        bntUpdateItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bntUpdateItem.setText("Update");
        bntUpdateItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntUpdateItemActionPerformed(evt);
            }
        });

        bntDeleteItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Delete-icon.png"))); // NOI18N
        bntDeleteItem.setText("Delete");
        bntDeleteItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntDeleteItemActionPerformed(evt);
            }
        });

        bntResetItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Undo-icon.png"))); // NOI18N
        bntResetItem.setText("Reset");
        bntResetItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntResetItemActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pn_ItemLayout = new javax.swing.GroupLayout(pn_Item);
        pn_Item.setLayout(pn_ItemLayout);
        pn_ItemLayout.setHorizontalGroup(
            pn_ItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_ItemLayout.createSequentialGroup()
                .addGroup(pn_ItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_ItemLayout.createSequentialGroup()
                        .addGap(98, 98, 98)
                        .addComponent(bntAddItem)
                        .addGap(54, 54, 54)
                        .addComponent(bntUpdateItem)
                        .addGap(60, 60, 60)
                        .addComponent(bntDeleteItem)
                        .addGap(58, 58, 58)
                        .addComponent(bntResetItem))
                    .addGroup(pn_ItemLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(pn_ItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        pn_ItemLayout.setVerticalGroup(
            pn_ItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_ItemLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pn_ItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bntAddItem)
                    .addComponent(bntUpdateItem)
                    .addComponent(bntDeleteItem)
                    .addComponent(bntResetItem))
                .addContainerGap(41, Short.MAX_VALUE))
        );

        tp_Admin.addTab("Items Manager", new javax.swing.ImageIcon(getClass().getResource("/Images/product-icon.png")), pn_Item); // NOI18N

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Categories Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_CateID.setText("Category ID :");

        lb_CateName.setText("Category Name :");

        txtCateID.setEnabled(false);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(144, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lb_CateID)
                    .addComponent(lb_CateName))
                .addGap(62, 62, 62)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtCateID)
                    .addComponent(txtCateName, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE))
                .addContainerGap(274, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCateID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_CateID))
                .addGap(35, 35, 35)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCateName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_CateName))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Categories List", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        tbCategory.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbCategory.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbCategoryMouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(tbCategory);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 758, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
        );

        bntAddCate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Add-icon.png"))); // NOI18N
        bntAddCate.setText("Add New");
        bntAddCate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntAddCateActionPerformed(evt);
            }
        });

        bntReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Undo-icon.png"))); // NOI18N
        bntReset.setText("Reset");
        bntReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntResetActionPerformed(evt);
            }
        });

        bntUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bntUpdate.setText("Update");
        bntUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntUpdateActionPerformed(evt);
            }
        });

        bntDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Delete-icon.png"))); // NOI18N
        bntDelete.setText("Delete");
        bntDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntDeleteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pn_CateLayout = new javax.swing.GroupLayout(pn_Cate);
        pn_Cate.setLayout(pn_CateLayout);
        pn_CateLayout.setHorizontalGroup(
            pn_CateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_CateLayout.createSequentialGroup()
                .addGroup(pn_CateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_CateLayout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addComponent(bntAddCate)
                        .addGap(71, 71, 71)
                        .addComponent(bntUpdate)
                        .addGap(82, 82, 82)
                        .addComponent(bntDelete)
                        .addGap(76, 76, 76)
                        .addComponent(bntReset))
                    .addGroup(pn_CateLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(pn_CateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        pn_CateLayout.setVerticalGroup(
            pn_CateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_CateLayout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(7, 7, 7)
                .addGroup(pn_CateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bntAddCate)
                    .addComponent(bntUpdate)
                    .addComponent(bntDelete)
                    .addComponent(bntReset))
                .addContainerGap(33, Short.MAX_VALUE))
        );

        tp_Admin.addTab("Categories Manager", new javax.swing.ImageIcon(getClass().getResource("/Images/packing-icon.png")), pn_Cate); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tp_Admin, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 795, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tp_Admin, javax.swing.GroupLayout.PREFERRED_SIZE, 549, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void bnt_ChangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnt_ChangeActionPerformed
        // TODO add your handling code here:
        if(ValidateInfoForm()==1) {
            String message = new AdminFunction().updateInfor_BL(user.getUserID(),txtName.getText(),txtPhone.getText(),txtEmail.getText(),txtAddress.getText());
            JOptionPane.showMessageDialog(this, message);
        }
}//GEN-LAST:event_bnt_ChangeActionPerformed

    private void bntChangePassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntChangePassActionPerformed
        // TODO add your handling code here:
        new ChangePass(user).setVisible(true);
}//GEN-LAST:event_bntChangePassActionPerformed

    private void bntAddUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntAddUserActionPerformed
        // TODO add your handling code here:
        if(ValidateUserForm()==1) {
            int InsertSuccess=function.Add_New_User(UID, RID, Name, UserName, Pass, Phone, Email, Address, Status);
            if(InsertSuccess == 1)
            {
                JOptionPane.showMessageDialog(this, "Add New User Successfully !","Notice !",2,null);
                getValuesForUserTable();
                ResetUserForm();
            }
            else
            {
                JOptionPane.showMessageDialog(this, "An Error occur,Add false !","Error !",2,null);
            }       
        }
}//GEN-LAST:event_bntAddUserActionPerformed

    public void getValuesForUserTable()
    {
        TableModel tbm=function.UserTable();
        tbUser.setModel(tbm);
    }


    private void bntResetUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntResetUserActionPerformed
        // TODO add your handling code here:
        ResetUserForm();
}//GEN-LAST:event_bntResetUserActionPerformed

    private void bntAddItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntAddItemActionPerformed
        // TODO add your handling code here:
        if(ValidateItemForm()==1) {
            int AddSuccess=function.Add_Item(IID,ICate,IName,IUnit,IQuantity,IPrice,IStatus);
            if(AddSuccess==1)
            {
                JOptionPane.showMessageDialog(this,"Add New Item Successfully !","Notice !",1,null);
                ItemList();
                ResetItemForm();
            }
            else
            {
                JOptionPane.showMessageDialog(this,"An Error Occur, Add false!","Error !",1,null);
            }
            
        }
}//GEN-LAST:event_bntAddItemActionPerformed

    private void bntUpdateItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntUpdateItemActionPerformed
        // TODO add your handling code here:
        if(ValidateItemForm()==1) {
            int UpdateSucces=function.UpdateItem(IID, ICate, IName, IUnit, IQuantity, IPrice);
            if(UpdateSucces==1)
            {
                JOptionPane.showMessageDialog(this,"Update Item Successfully !","Notice !",1,null);
                ItemList();
            }
            else
            {
                JOptionPane.showMessageDialog(this,"An Error occur ,Update false !","Error !",1,null);
            }
            
        }
}//GEN-LAST:event_bntUpdateItemActionPerformed

    private void bntDeleteItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntDeleteItemActionPerformed
        // TODO add your handling code here:
        if(txtIID.getText().equals("")) {
            JOptionPane.showMessageDialog(this,"Choice Item ID!","Error !",2,null);
            txtIID.requestFocus();
        } else {
            int deleteSuccess=function.DeleteItem(IID);
            if(deleteSuccess==1)
            {
                JOptionPane.showMessageDialog(this,"Delete Item Successfully !","Notice !",2,null);
                ItemList();
            }
            else{
                JOptionPane.showMessageDialog(this,"An Error Occur,Delete false !","Error !",2,null);
            }
            
        }
}//GEN-LAST:event_bntDeleteItemActionPerformed

    private void bntResetItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntResetItemActionPerformed
        // TODO add your handling code here:
        txtIID.setText("");
        txtIName.setText("");
        cbCate.setSelectedIndex(0);
        txtQuantity.setText("");
        txtPrice.setText("");
        txtUnit.setText("");
        buttonGroup1.clearSelection();
}//GEN-LAST:event_bntResetItemActionPerformed

    private void bntAddCateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntAddCateActionPerformed
        // TODO add your handling code here:
        if(ValidateCateForm()==1) {
            int AddSuccess=function.AddCate(CateName,CateStatus);
            if(AddSuccess == 1)
            {
                JOptionPane.showMessageDialog(this,"Add New Category Successfully !","notice !",1,null);
                GenerateCateID();
                CateList();
                txtCateName.setText("");
            }
            else
            {
                JOptionPane.showMessageDialog(this,"An Error occur,Insert false !","Error !",2,null);
            }
            
        }
}//GEN-LAST:event_bntAddCateActionPerformed

    private void bntResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntResetActionPerformed
        // TODO add your handling code here:
        GenerateCateID();
        txtCateName.setText("");
}//GEN-LAST:event_bntResetActionPerformed

    private void bntUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntUpdateActionPerformed
        // TODO add your handling code here:
        if(ValidateCateForm()==1) {
            int CateID=Integer.parseInt(txtCateID.getText());
            int updateSuccess=function.UpdateCate(CateID, CateName);
            if(updateSuccess==1)
            {
                JOptionPane.showMessageDialog(this,"Update Category Successfully!","Notice !",1,null);
                txtCateName.setText("");
                CateList();
            }
            else
            {
                JOptionPane.showMessageDialog(this,"An Error Occur, Update false!","Error !",2,null);
            }
            
        }
}//GEN-LAST:event_bntUpdateActionPerformed

    private void bntDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntDeleteActionPerformed
        // TODO add your handling code here:
        int CurrID=Integer.parseInt(txtCateID.getText());
        int C_ID=function.GenerateCID();
        if(CurrID > C_ID) {
            JOptionPane.showMessageDialog(this,"Choice Category to Delete!","OK !",1,null);
        } else {
            int deleteSuccess=function.DeleteCate(CurrID);
            if(deleteSuccess == 1)
            {
                JOptionPane.showMessageDialog(this,"Delete Category Successfully !","Notice !",1,null);
                CateList();
                txtCateName.setText("");
                GenerateCateID();
            }
            else{
                JOptionPane.showMessageDialog(this,"An Error Occur, Delete false !","Error !",2,null);
            }
        }
}//GEN-LAST:event_bntDeleteActionPerformed

    private void bntUpdateUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntUpdateUserActionPerformed
        // TODO add your handling code here:
        if(ValidateUserForm()==1)
        {
            int UpdateOK = function.UpdateUser(UID, RID, Status);
            System.out.println(""+UID+RID+Status);
            if(UpdateOK==1)
            {
                JOptionPane.showMessageDialog(this, "Update User Successfully !","Notice !",2,null);
            }
            getValuesForUserTable();
        }
}//GEN-LAST:event_bntUpdateUserActionPerformed

    private void tbUserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbUserMouseClicked
        // TODO add your handling code here:
        int counts = tbUser.getSelectedRow();
        String _UID = (String) tbUser.getValueAt(counts, 0);
        String _RID = (String) tbUser.getValueAt(counts, 1);
        String _Name = (String) tbUser.getValueAt(counts, 2);
        String _UserName = (String) tbUser.getValueAt(counts, 3);
        String _Password = (String) tbUser.getValueAt(counts, 4);
        String _Phone = (String) tbUser.getValueAt(counts, 5);
        String _Email = (String) tbUser.getValueAt(counts, 6);
        String _Address = (String) tbUser.getValueAt(counts, 7);
        String _Status = (String) tbUser.getValueAt(counts, 9);

        txtUID.setText(_UID);
        txtName1.setText(_Name);
        txtEmail1.setText(_Email);
        txtPhone1.setText(_Phone);
        txtAddress1.setText(_Address );
        txtUserName1.setText(_UserName);
        txtPass1.setText(_Password);

        cbRoles.setSelectedIndex(function.getPer(_RID));

        if (_Status.equals("1")) {
            rbEnable.setSelected(true);
            rbDisable.setSelected(false);
        } else {
            rbEnable.setSelected(false);
            rbDisable.setSelected(true);
        }
    }//GEN-LAST:event_tbUserMouseClicked

    private void tbCategoryMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbCategoryMouseClicked
        // TODO add your handling code here:
        int counts = tbCategory.getSelectedRow();
        String ID = (String) tbCategory.getValueAt(counts, 0);
        String CName = (String) tbCategory.getValueAt(counts, 1);

        txtCateID.setText(ID);
        txtCateName.setText(CName);
    }//GEN-LAST:event_tbCategoryMouseClicked

    private void tbItemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbItemMouseClicked
        // TODO add your handling code here:
        int counts = tbItem.getSelectedRow();
        String _IID = (String) tbItem.getValueAt(counts, 0);
        String _IName = (String) tbItem.getValueAt(counts, 2);
        String _Unit = (String) tbItem.getValueAt(counts, 3);
        String _Quantity = (String) tbItem.getValueAt(counts, 4);
        String _Price = (String) tbItem.getValueAt(counts, 5);

        txtIID.setText(_IID);
        txtIName.setText(_IName);
        txtPrice.setText(_Price);
        txtQuantity.setText(_Quantity);
        txtUnit.setText(_Unit);   
    }//GEN-LAST:event_tbItemMouseClicked
    //method validate Information form
    public int ValidateInfoForm()
    {
        InfoName=txtName.getText();
        InfoPhone=txtPhone.getText();
        InfoEmail=txtEmail.getText();
        InfoAddress=txtAddress.getText();
        InfoUserName=txtUserName.getText();
        InfoRoles=txtRoles.getText();
        String per=txtPer.getText();
        if(InfoName.equals(""))
        {
            JOptionPane.showMessageDialog(this,"Enter Your Name !","Error !",2,null);
            txtName.requestFocus();
            return 0;
        }
        else if(InfoPhone.equals(""))
        {
            JOptionPane.showMessageDialog(this,"Enter Your Phone Number !","Error !",2,null);
            txtPhone.requestFocus();
            return 0;
        }
        else if(InfoEmail.equals(""))
        {
            JOptionPane.showMessageDialog(this,"Enter Your Contac Email !","Error !",2,null);
            txtEmail.requestFocus();
            return 0;
        }
        else if(InfoAddress.equals(""))
        {
            JOptionPane.showMessageDialog(this,"Enter Your Address !","Error !",2,null);
            txtAddress.requestFocus();
            return 0;
        }
        return 1;
    }

    //method validate User form
    public int ValidateUserForm()
    {
        char[] temp1=txtPass1.getPassword();
        Pass=String.copyValueOf(temp1);
        UID=txtUID.getText();
        String Role = cbRoles.getSelectedItem().toString();
        RID=function.getRID(Role);
        UserName=txtUserName1.getText();
        Phone=txtPhone1.getText();
        Email=txtEmail1.getText();
        Address=txtAddress1.getText();
        Per=cbRoles.getSelectedIndex();
        int StatusChoice=0;
        if(rbEnable.isSelected())
        {
            Status=1;
            StatusChoice=1;
        }
        else if(rbDisable.isSelected())
        {
            Status=0;
            StatusChoice=1;
        }
        Name=txtName1.getText();

        if(UID.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter User ID !","Error !",2,null);
            txtUID.requestFocus();
            return 0;
        }
        else if(Email.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter User Email !","Error !",2,null);
            txtEmail1.requestFocus();
            return 0;
        }
        else if(Phone.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter User Phone !","Error !",2,null);
            txtPhone1.requestFocus();
            return 0;
        }
        else if(Address.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter User Address !","Error !",2,null);
            txtAddress1.requestFocus();
            return 0;
        }
        else if(UserName.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter UserName !","Error !",2,null);
            txtUserName1.requestFocus();
            return 0;
        }
        else if(Pass.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter User Password!","Error !",2,null);
            txtPass1.requestFocus();
            return 0;
        }
        else if(Per==0)
        {
            JOptionPane.showMessageDialog(this, "Choice User Roles!","Error !",2,null);
            cbRoles.requestFocus();
            return 0;
        }
        else if(StatusChoice==0)
        {
            JOptionPane.showMessageDialog(this, "Choice Status of User !","Error !",2,null);
            return 0;
        }
        Pattern PhonePattern=Pattern.compile("[a-zA-Z]");
        Matcher PhoneMatcher=PhonePattern.matcher(Phone);
        if(PhoneMatcher.find())
        {
            JOptionPane.showMessageDialog(this, "Phone Number must not containt character !","Error !",2,null);
            txtPhone1.setText("");
            txtPhone1.requestFocus();
            return 0;
        }
        Pattern NamePattern=Pattern.compile("[\\d]");
        Matcher NameMatcher=NamePattern.matcher(Name);
        if(NameMatcher.find())
        {
            JOptionPane.showMessageDialog(this, "Name must not containt digit !","Error !",2,null);
            txtName1.setText("");
            txtName1.requestFocus();
            return 0;
        }

        Pattern EmailPattren=Pattern.compile("^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$");
        Matcher EmailMatcher=EmailPattren.matcher(Email);
        if(!EmailMatcher.find())
        {
            JOptionPane.showMessageDialog(this, "Invalid Email Address !","Error !",2,null);
            txtEmail1.setText("");
            txtEmail1.requestFocus();
            return 0;
        }
        return 1;
    }


    //method reset User form
    public void ResetUserForm()
    {
       txtUID.setEditable(true);
       txtUserName1.setEditable(true);
       txtName1.setText("");
       txtPass1.setText("");
       txtUID.setText("");
       cbRoles.setSelectedIndex(0);
       txtUserName1.setText("");
       txtPhone1.setText("");
       txtEmail1.setText("");
       txtAddress1.setText("");
       buttonGroup2.clearSelection();
    }

    public void ResetItemForm()
    {
        txtIID.setText("");
        txtIName.setText("");
        txtUnit.setText("");
        txtQuantity.setText("");
        txtPrice.setText("");
        cbCate.setSelectedIndex(0);
    }

    //method validate Item form
    public int ValidateItemForm()
    {
        int check=1;
        IID=txtIID.getText();
        IName=txtIName.getText();
        IUnit=txtUnit.getText();
        String quantity=txtQuantity.getText();
        String price=txtPrice.getText();
        String Cate=cbCate.getSelectedItem().toString();
        ICate=function.getCateID(Cate);
        int Cate_Choice=cbCate.getSelectedIndex();       
        IStatus=1;
        if(IID.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter Item ID !","Error !",2,null);
            txtIID.requestFocus();
            check=0;
        }
        else if(IName.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter Item Name !","Error !",2,null);
            txtIName.requestFocus();
            check=0;
        }
        else if(IUnit.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter Item Unit !","Error !",2,null);
            txtUnit.requestFocus();
            check=0;
        }
        else if(quantity.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter Item Quantity !","Error !",2,null);
            txtQuantity.requestFocus();
            check=0;
        }
        else if(price.equals(""))
        {
            JOptionPane.showMessageDialog(this, "Enter Item Price !","Error !",2,null);
            txtPrice.requestFocus();
            check=0;
        }
        else if(Cate_Choice==0)
        {
            JOptionPane.showMessageDialog(this, "Choice Item's Category !","Error !",2,null);
            txtIID.requestFocus();
            check=0;
        }
        if(check==1)
        {
            IQuantity=Integer.parseInt(quantity);
            IPrice=Float.parseFloat(price);
        }
        return check;
    }

    //method validate Category Form
    public int ValidateCateForm()
    {
        CateName=txtCateName.getText();
        CateStatus=1;
        if(CateName.equals(""))
        {
            JOptionPane.showMessageDialog(this,"Enter Category Name","Error !",2,null);
            txtCateName.requestFocus();
            return 0;
        }
        return 1;
    }

    public void GenerateCateID()
    {
        int ID=function.GenerateCID();
        String CateID=String.valueOf((ID+1));
        txtCateID.setText(CateID);
    }
    public void CategoryList()
    {
        Vector CateList=function.getCategory();
        for(Object o : CateList)
        {
            cbCate.addItem(o);
        }
    }

    public void ItemList()
    {
       TableModel tbm=function.ItemTable();
        tbItem.setModel(tbm);
    }

    public void CateList()
    {
       TableModel tbm=function.CateTable();
        tbCategory.setModel(tbm);
    }
    //variable for User Form
    String UID;
    String RID;
    String UserName;
    String Pass;
    String Phone;
    String Email;
    String Address;
    int Per;
    int Status;
    String Name;

    //Variable for Item Form
    String IID;
    String IName;
    String IUnit;
    int IQuantity;
    float IPrice;
    int IStatus;
    int ICate;

    //variable for Category Form
    String CateName;
    int CateStatus;
    //variable for Information form
    String InfoName;
    String InfoPhone;
    String InfoEmail;
    String InfoAddress;
    String InfoUserName;
    String InfoRoles;
    int InfoPermission;

    private AdminFunction function;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bntAddCate;
    private javax.swing.JButton bntAddItem;
    private javax.swing.JButton bntAddUser;
    private javax.swing.JButton bntChangePass;
    private javax.swing.JButton bntDelete;
    private javax.swing.JButton bntDeleteItem;
    private javax.swing.JButton bntReset;
    private javax.swing.JButton bntResetItem;
    private javax.swing.JButton bntResetUser;
    private javax.swing.JButton bntUpdate;
    private javax.swing.JButton bntUpdateItem;
    private javax.swing.JButton bntUpdateUser;
    private javax.swing.JButton bnt_Change;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JComboBox cbCate;
    private javax.swing.JComboBox cbRoles;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JLabel lb_Address;
    private javax.swing.JLabel lb_Address1;
    private javax.swing.JLabel lb_Cate;
    private javax.swing.JLabel lb_CateID;
    private javax.swing.JLabel lb_CateName;
    private javax.swing.JLabel lb_Email;
    private javax.swing.JLabel lb_Email1;
    private javax.swing.JLabel lb_IID;
    private javax.swing.JLabel lb_IName;
    private javax.swing.JLabel lb_Name;
    private javax.swing.JLabel lb_Price;
    private javax.swing.JLabel lb_Quantity;
    private javax.swing.JLabel lb_Roles;
    private javax.swing.JLabel lb_Roles1;
    private javax.swing.JLabel lb_Unit;
    private javax.swing.JLabel lb_permis;
    private javax.swing.JLabel lb_phone;
    private javax.swing.JLabel lb_phone1;
    private javax.swing.JLabel lb_username;
    private javax.swing.JLabel lb_username1;
    private javax.swing.JPanel pn_Cate;
    private javax.swing.JPanel pn_Item;
    private javax.swing.JPanel pn_MangerInfo;
    private javax.swing.JPanel pn_MangerInfo1;
    private javax.swing.JPanel pn_PersonInfo;
    private javax.swing.JPanel pn_PersonInfo1;
    private javax.swing.JPanel pn_info;
    private javax.swing.JPanel pn_user;
    private javax.swing.JRadioButton rbDisable;
    private javax.swing.JRadioButton rbEnable;
    private javax.swing.JTable tbCategory;
    private javax.swing.JTable tbItem;
    private javax.swing.JTable tbUser;
    public javax.swing.JTabbedPane tp_Admin;
    private javax.swing.JTextArea txtAddress;
    private javax.swing.JTextArea txtAddress1;
    private javax.swing.JTextField txtCateID;
    private javax.swing.JTextField txtCateName;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtEmail1;
    private javax.swing.JTextField txtIID;
    private javax.swing.JTextField txtIName;
    private javax.swing.JTextField txtName;
    private javax.swing.JTextField txtName1;
    private javax.swing.JPasswordField txtPass1;
    private javax.swing.JTextField txtPer;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JTextField txtPhone1;
    private javax.swing.JTextField txtPrice;
    private javax.swing.JTextField txtQuantity;
    private javax.swing.JTextField txtRoles;
    private javax.swing.JTextField txtUID;
    private javax.swing.JTextField txtUnit;
    private javax.swing.JTextField txtUserName;
    private javax.swing.JTextField txtUserName1;
    // End of variables declaration//GEN-END:variables

}
